using Z = Mint<998244353>;
void solve()
{
	int n;
	cin >> n;

	vector<vector<int>> g(n + 1);
	for (int i = 2; i <= n; i++) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	vector<int> dep(n + 1), son(n + 1, -1), mi(n + 1, inf);
	vector<Z> f(n + 1);

	auto dfs1 = [&](auto &&dfs1, int u, int fa) -> void {
		dep[u] = dep[fa] + 1;
		bool leaf = true;
		for (auto &v : g[u]) {
			if (v != fa) {
				leaf = false;
				dfs1(dfs1, v, u);
				if (son[u] == -1 || mi[u] > mi[v]) {
					son[u] = v;
					mi[u] = mi[v];
				}
			}
		}
		if (leaf) {
			mi[u] = dep[u];
			return ;
		}
		int d = mi[u] - dep[u] + 1; 
		f[u] = Z(d - 1) / Z(d);
	};
	dfs1(dfs1, 1, 0);
	f[1] = 1;
	auto dfs2 = [&](auto &&dfs2, int u, int fa) -> void {
		for (auto &v : g[u]) {
			if (v != fa) {
				f[v] *= f[u];
				dfs2(dfs2, v, u);
			}
		}
	};
	dfs2(dfs2, 1, 0);
	for (int i = 1; i <= n; i++) {
		cout << f[i] << " \n"[i == n];
	}
}